<html xmlns="http://www.w3.org/1999/xhtml"><head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>悬赏积分</title>
	<link rel="stylesheet" href="css/index.css">
	<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="js/index.js"></script>
</head>
<body>

<div id="top">
	<span id="send"></span>
</div>

<div id="main" >

</div>


<!--[if IE 6]>
<script type="text/javascript" src="js/iepng.js"></script>
<script type="text/javascript">
	DD_belatedPNG.fix('#send,#close,.close');
</script>
<![endif]-->
<script>
	jQuery(document).ready(function() {

		$.ajax({
			url:'/xsjf/getXsjf',
			data:'',
			dataType:'json',
			type:'get',
			success: function(data){
				console.log(data)
				$.each(data,function(index,jfxs){
					$('#main').append(element(jfxs));
				});
				var paper = $( '.paper' );
				var FW = $( window ).width();
				var FH = $( '#main' ).height();
				for (var i = 0; i < paper.length; i++) {
					var obj = paper.eq(i);
					obj.css( {
						left : parseInt(Math.random() * (FW - obj.width())) + 'px',
						top : parseInt(Math.random() * (FH - obj.height()) * 0.614) + 'px'
					} );
					drag(obj, $( 'dt', obj ));
				}
				paper.click( function () {
					$( this ).css( 'z-index', 1 ).siblings().css( 'z-index', 0 );
				} );
				$( '.close2' ).click( function () {
					$( this ).parents( 'dl' ).fadeOut('slow');
					return false;
				} );
			},
			error: function() {
			}
		});

		var element = function(jfxs) {
			var xscontent = jfxs.xscontent;
			var str = '';
			str += '<dl class="paper ' + random(1,5) + '" id="dl' + jfxs.xsid + '">';
			str += '<dt>';
			str += '<span class="username">' + jfxs.xstitle + '</span>';
			str += '</dt>';
			str += '<dd class="content"><br/>' + xscontent + '</dd>';
			str += '<dd class="bottom">';
			str += '<span class="time">悬赏分:<font color="red">'+ jfxs.xsintegral +'<font>&nbsp;<a class="reach" href="javascript:ling('+jfxs.xsid+');" style="color:#3875D7"><strong>领取任务</strong></a></span>';
			str += '<a href="" class="close2"></a>';
			str += '</dd>';
			str += '</dl>';
			return str;
		}
		var random = function (n,m){
			var str = Math.floor(Math.random() * (m-n+1) + n);
			if (str == 1) {
				return 'a1';
			}else if (str == 2) {
				return 'a2';
			}else if (str == 3) {
				return 'a3';
			}else if (str == 4) {
				return 'a4';
			}else{
				return 'a5';
			};
		}
	});

	function ling(xsid){
		$.ajax({
			url:"/xsjf/UpdStatus",
			data:{id:xsid},
			success:function(){
				alert("成功")
				location.reload();
			}
		})
	}
</script>
</body>
</html>